home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / msdos / mxmenu.zip / MARXCOM.MNU < prev    next >
Text File  |  1993-07-15  |  7KB  |  322 lines

  1. Comment
  2. ==========================================================
  3.  
  4. Copyright 1992-93 by Marc Perkel * All right reserved.
  5.  
  6. This program is a sample communications program in Marxmenu.
  7. It isn't as good as Procomm, but it isn't half bad for a few
  8. pages of code.
  9.  
  10. =========================================================
  11. EndComment
  12.  
  13. Var
  14.   InitString
  15.   Compuserve
  16.   StartTime
  17.   LastFile
  18.   SendingFile
  19.  
  20.  
  21. Setup
  22. ComPort = Com2             ;your com port
  23. InitString = 'ATZ'         ;your init string
  24. Compuserve = False         ;set to true if accessing Compuserve
  25. ComInitPort(38400,8,'N',1)
  26. if ComResult <> 0
  27.    Writeln
  28.    Writeln "Can't initialze serial port!"
  29.    ExitMenu
  30. endif
  31.  
  32. ComHangupOnExit Off
  33.  
  34. if Compuserve
  35.    ComStripHighBit
  36.    ComBPlus
  37. endif
  38.  
  39. Writeln 'MarxCom * Copyright 1992-93 by Marc Perkel'
  40. Writeln
  41. Writeln 'Alt-X to Exit * Alt-H to HangUp * PgUp to Upload * PgDn to Download
  42. Writeln
  43. ComWrite InitString CR
  44.  
  45. Terminal
  46.  
  47. ;----- Set up Communications
  48.  
  49. Procedure Setup
  50.    Explode Off
  51.    ClearScreenOnExit Off
  52.    BlankTime = 0
  53.    Mouse Off
  54.    NoBoxBorder
  55.    AnsiWindows
  56.    DrawBox 1 1 ScreenWidth ScreenHeight
  57.    WordStarKeys Off
  58.    {Set up event logic}
  59.  
  60.    KeyEvent(PgDnKey) = loc DownLoad
  61.    KeyEvent(PgUpKey) = loc UpLoad
  62.    KeyEvent(AltX)  = loc ExitProgram
  63.    KeyEvent(AltH)  = loc Hangup
  64.    ComXmitAbortProgram = loc XmitAbort
  65.    ComXmitStatusProgram = loc XmitStatus
  66.    if NovDefaultServer = 'MARX'
  67.       ComNewLineProgram = loc ExamineLastLine
  68.    endif
  69. EndProc
  70.  
  71.  
  72. ;----- This is the main terminal loop
  73.  
  74. Procedure Terminal
  75.    while True
  76.       Cursor On
  77.       if ComCharReady then Write(ComReadChar)
  78.       if KbdReady then ComWrite(ReadKey)
  79.    endwhile
  80. EndProc
  81.  
  82.  
  83. ;----- Exit the Menu
  84.  
  85. Procedure ExitProgram
  86.    ExitMenu
  87. EndProc
  88.  
  89.  
  90. ;----- Download Menu
  91.  
  92. Procedure DownLoad
  93. var FileName Proto
  94.    Proto = PickProtocol
  95.    if Proto = Esc
  96.       Return
  97.  
  98.    elseif Proto = '1'
  99.       FileName = AskForFileName
  100.       if FileName = '' then return
  101.       ComRecXModem(FileName)
  102.  
  103.    elseif Proto = '2'
  104.       FileName = AskForFileName
  105.       if FileName = '' then return
  106.       ComRec1kXModem(FileName)
  107.  
  108.    elseif Proto = '3'
  109.       ComRecYModem
  110.  
  111.    elseif Proto = '4'
  112.       ComRecYModemG
  113.  
  114.    elseif Proto = '5'
  115.       ComRecZModem
  116.  
  117.    elseif Proto = '6'
  118.       ComRecKermit
  119.  
  120.    endif
  121.    if ComResult <> 0
  122.       Writeln 'Error Status: ' ComResult
  123.       Wait 400
  124.    endif
  125. EndProc
  126.  
  127.  
  128. ;----- UpLoad Menu
  129.  
  130. Procedure UpLoad
  131. var FileName Proto
  132.    FileName = AskForFileName
  133.    if (FileName > '') and ExistFile(FileName)
  134.       Proto = PickProtocol
  135.       if Proto = Esc then Return
  136.  
  137.       SendingFile
  138.       FileName = CleanFileName(FileName)
  139.       Writeln
  140.  
  141.       if Proto = '1'
  142.          ComSendXModem(FileName)
  143.  
  144.       elseif Proto = '2'
  145.          ComSend1kXModem(FileName)
  146.  
  147.       elseif Proto = '3'
  148.          ComSendYModem(FileName)
  149.  
  150.       elseif Proto = '4'
  151.          ComSendYModemG(FileName)
  152.  
  153.       elseif Proto = '5'
  154.          ComSendZModem(FileName)
  155.  
  156.       elseif Proto = '6'
  157.          ComSendKermit(FileName)
  158.  
  159.       endif
  160.  
  161.    endif
  162.    SendingFile Off
  163. EndProc
  164.  
  165.  
  166. Procedure AskForFileName
  167. var FileName
  168.    DoubleLineBox
  169.    BoxBorderColor LCyan Mag
  170.    BoxInsideColor Yellow Mag
  171.    InverseColor Yellow Red
  172.    DrawBox 10 20 40 3
  173.    Write ' FileName: '
  174.    FileName = Readln
  175.    EraseTopWindow
  176.    Return FileName
  177. EndProc
  178.  
  179.  
  180. Procedure PickProtocol
  181. var Ch
  182.    DoubleLineBox
  183.    BoxBorderColor LCyan Mag
  184.    BoxInsideColor Yellow Mag
  185.    InverseColor Yellow Red
  186.    DrawBox 50 7 20 8
  187.    UseArrows On
  188.    Writeln '  1 - XModem'
  189.    Writeln '  2 - XModem 1k'
  190.    Writeln '  3 - YModem'
  191.    Writeln '  4 - YModem G'
  192.    Writeln '  5 - ZModem'
  193.    Write   '  6 - Kermit'
  194.    Ch = ReadKey
  195.    UseArrows Off
  196.    EraseTopWindow
  197.    Return Ch
  198. EndProc
  199.  
  200.  
  201. ;----- Hangup Modem
  202.  
  203. Procedure HangUp
  204.    Writeln
  205.    Writeln
  206.    Writeln 'Hanging Up'
  207.    Writeln
  208.    ComDTR Off
  209.    Wait 50
  210.    ComDTR
  211. EndProc
  212.  
  213.  
  214. ;----- ESC aborts UpLoad or Download
  215.  
  216. Procedure XmitAbort
  217. var Ch
  218.    if not ComCD then Return True
  219.    if not KbdReady then Return False
  220.    Ch = ReadKey
  221.    if Ch <> Esc then Return False
  222.    Return True
  223. EndProc
  224.  
  225.  
  226. ;----- Display file transfer status
  227.  
  228. Procedure XmitStatus
  229. var Progress BarSize X
  230.    if ComXmitStarting
  231.       DoubleLineBox
  232.       BoxBorderColor LCyan Mag
  233.       BoxInsideColor White Mag
  234.       BoxHeaderColor Yellow Cyan
  235.       BoxHeader ' Transfer Status - ' + ComProtocol + ' '
  236.       if SendingFile
  237.          DrawBox 43 6 35 10
  238.       else
  239.          DrawBox 43 6 35 11
  240.       endif
  241.  
  242.    elseif ComXmitEnding
  243.       EraseTopWindow
  244.       LastFile = ''
  245.    else
  246.  
  247.       BarSize = 37
  248.       if ComFileName <> LastFile
  249.          LastFile = ComFileName
  250.          StartTime = Now
  251.       endif
  252.       GotoXY 1 1
  253.       Write '         File Name: ' ComFileName
  254.       ClearLine
  255.       Writeln
  256.       Write ' Bytes Transferred: ' ComBytesTransferred
  257.       ClearLine
  258.       Writeln
  259.       Write '   Bytes Remaining: ' ComBytesRemaining
  260.       ClearLine
  261.       Writeln
  262.       if not SendingFile
  263.          Write '               CPS: '
  264.          if Now > StartTime
  265.             X = ComBytesTransferred / (Now - StartTime)
  266.             if X > 0
  267.                X = X / (X / 20) * (X / 20)
  268.             endif
  269.             Write X
  270.          else
  271.             Write '0'
  272.          endif
  273.          ClearLine
  274.          Writeln
  275.       endif
  276.       Write '         File Size: ' ComFileSize
  277.       ClearLine
  278.       Writeln
  279.       Write '        Block Size: ' ComBlockSize
  280.       ClearLine
  281.       Writeln
  282.       Write '      Block Errors: ' ComBlockErrors
  283.       ClearLine
  284.       Writeln
  285.       Write '      Total Errors: ' ComTotalErrors
  286.       ClearLine
  287.  
  288.       if ComFileSize > 0
  289.          Progress = ComBytesTransferred * BarSize / ComFileSize
  290.       endif
  291.       if ComFileSize > 0
  292.          Writeln
  293.          Write ' Progress: ['
  294.          if ColorScreen then TextColor Cyan Mag
  295.          Loop Progress / 2
  296.             Write '█'
  297.          endloop
  298.          if Progress mod 2 = 0
  299.             Write ' '
  300.          else
  301.             Write '▌'
  302.          endif
  303.          Loop Max(BarSize - Progress / 2 - 1,0)
  304.             Write ' '
  305.          endloop
  306.          TextColor White Mag
  307.          Write ']'
  308.          ClearLine
  309.       endif
  310.    endif
  311. EndProc
  312.  
  313.  
  314. ;----- When calling my BBS I syncronize my server clock to the office.
  315.  
  316. Procedure ExamineLastLine
  317. var P
  318.    P = pos('Time Sync:',ComLastLine)
  319.    if P = 0 then Return
  320.    NovServerTime = TimeOf(mid(ComLastLine,P + 11,17))
  321. EndProc
  322.